package com.jysz.certificate.persistence.enums;

import com.jysz.webcore.ssh.web.convert.IEnum;

/**
 * 行政区域类型
 * 
 * @author <a href="mailto:javaengine@outlook.com">Kaca Rich</a>
 * 
 */
public enum RegionEnum implements IEnum{

	COUNTRY("国家", 0), PROVINCE("省", 1), CITY("市", 2),AREA("区", 3);

	// 名称
	private String name;
	// 索引
	private int index;


	private RegionEnum(String name, int index) {
		this.name = name;
		this.index = index;
	}

	// 根据索引获得名称
	public static String getName(int index) {
		for (RegionEnum w : RegionEnum.values()) {
			if (w.getIndex() == index) {
				return w.name;
			}
		}
		return null;
	}
	
	public static RegionEnum next(RegionEnum pre){
		return index(pre.index+1);
	}
	public static RegionEnum index(int index) {
		for (RegionEnum r : RegionEnum.values()) {
			if (r.getIndex() == index) {
				return r;
			}
		}
		return null;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	@Override
	public String toString() {
		return this.getName();
	}
}
